package org.example.nt.ssl;

import sun.security.jca.GetInstance;

import javax.net.ssl.*;
import java.security.*;

public class GmSSLContext extends SSLContext {
    private final Provider provider;
    private final GmSSLContextSpi contextSpi;
    private final String protocol;
    private static GmSSLContext defaultContext;
    protected GmSSLContext(GmSSLContextSpi sslContextSpi, Provider provider, String protocol) {
        super(sslContextSpi, provider, protocol);
        this.provider = provider;
        this.contextSpi = sslContextSpi;
        this.protocol = protocol;
    }

    public static synchronized SSLContext getDefault() throws NoSuchAlgorithmException {
        if (defaultContext == null) {
            defaultContext = getInstance("Default");
        }

        return defaultContext;
    }

    public static synchronized void setDefault(SSLContext var0) {
        if (var0 == null) {
            throw new NullPointerException();
        } else {
            SecurityManager var1 = System.getSecurityManager();
            if (var1 != null) {
                var1.checkPermission(new SSLPermission("setDefaultSSLContext"));
            }

            defaultContext = (GmSSLContext) var0;
        }
    }

    public static GmSSLContext getInstance(String var0) throws NoSuchAlgorithmException {
        GetInstance.Instance contextSpi = GetInstance.getInstance("GmSSLContext", GmSSLContextSpi.class, var0);
        return new GmSSLContext((GmSSLContextSpi)contextSpi.impl, contextSpi.provider, var0);
    }

    public static SSLContext getInstance(String var0, String var1) throws NoSuchAlgorithmException, NoSuchProviderException {
        GetInstance.Instance var2 = GetInstance.getInstance("GmSSLContext", GmSSLContextSpi.class, var0, var1);
        return new GmSSLContext((GmSSLContextSpi)var2.impl, var2.provider, var0);
    }

    public static GmSSLContext getInstance(String var0, Provider var1) throws NoSuchAlgorithmException {
        GetInstance.Instance var2 = GetInstance.getInstance("GmSSLContext", GmSSLContextSpi.class, var0, var1);
        return new GmSSLContext((GmSSLContextSpi)var2.impl, var2.provider, var0);
    }
}
